<?php
namespace app\admin\model;

use think\Db;
use think\Request;
use app\admin\model\Base;

class Courseclassify extends Base{

    //课程分类管理首页
    public function  index(){

        $res = Db::table('courseclassify')->select();
        return $res;
    }

    //删除课程分类
    public function delete(){

        $request = Request::instance()->get();
        $id = $request['id'];
        $dataifid = $request["dataifid"];



        if($dataifid == "1"){

            $res = Db::table('courseclassify')->where('classify_id',$id)->update(['classify_del' => 0]);

        }else if($dataifid == "2"){

            $res = Db::table('courseclassify')->where('classify_id',$id)->update(['classify_del' => 1]);

        }else if($dataifid == "3"){

            $res = $this->updateOne("courseclassify","classify_id = $id");
        }

        return $res;

    }

    //新增课程分类
    public function classifyInsert(){

        $request = Request::instance()->post();

        $data = array();
        $data['course_classify'] = $request['course_classify'];
        $data['classify_del'] = 0;

        $res = $this->add("courseclassify",$data);

        return $res;

    }

}

